@namespace BulmaRazor.Components
@inherits BulmaComponentBase
@inject BulmaRazorJsInterop JsInterop
<li id="@Id" @attributes="Attributes" class="@classes">
    <CascadingValue Value="this">
        @ChildContent
    </CascadingValue>
</li>

@code{
    private readonly string Id = "menuitem_" + Guid.NewGuid().ToString("N");

    string classes => CssBuilder.Default("")
        .AddClassFromAttributes(Attributes)
        .Build();

    internal MenuLink Title { get; set; }

    internal MenuList SubList { get; set; }

    
    [CascadingParameter]
    public MenuList ListParent { get; set; }

    [CascadingParameter]
    public Menu MenuParent { get; set; }

    [Parameter]
    public RenderFragment ChildContent { get; set; }

    protected override void OnInitialized()
    {
        base.OnInitialized();
        MenuParent?.AddItem(this);
    }

}